package chan.project.model.enums;

import chan.project.common.ErrorCode;
import chan.project.exception.ThrowUtils;
import lombok.Getter;

public enum ReviewStatusEnum {
    PENDING_REVIEW(0,"待审核"),
    APPROVED(1,"审核通过"),
    REJECTED(2,"拒绝");

    @Getter
    private final Integer value;

    private final String text;

    ReviewStatusEnum(Integer value, String text){
        this.value = value;
        this.text = text;
    }

    public static ReviewStatusEnum getReviewStatusEnum(Integer value){
        ThrowUtils.throwIf(value == null, ErrorCode.PARAMS_ERROR);
        for (ReviewStatusEnum reviewStatusEnum : ReviewStatusEnum.values()) {
            if (reviewStatusEnum.getValue().equals(value)){
                return reviewStatusEnum;
            }
        }
        return null;
    }

}
